package com.oritsh.dicom.utils.adaptor;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.ObjectCodec;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import org.dcm4che.data.Attributes;

import java.io.IOException;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: zarra
 * Date: 14-2-5
 * Time: 下午5:24
 * Copyright Shanghai Orient Rain Information Technology Co.,Ltd.
 */
public class AttributesJacksonDeserializer extends JsonDeserializer<Attributes> {
    @Override
    public Attributes deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
        ObjectCodec oc = jp.getCodec();
        Map<String,Object> map = oc.readValue(jp,Map.class);
        return JsonAdaptorHelper.mapToAttributes(map);
    }
}
